package com.joysuch.wwyt.quartz.licence;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.joysuch.wwyt.api.alarmbluetooth.exception.BizException;
import com.joysuch.wwyt.bp.entity.BpEnterpriseInfo;
import com.joysuch.wwyt.bp.service.BpEnterpriseInfoService;
import com.joysuch.wwyt.common.entity.CommonVersion;
import com.joysuch.wwyt.common.service.CommonVersionService;
import com.joysuch.wwyt.config.RedisClient;
import com.joysuch.wwyt.core.entity.BaseModuleMenuMapping;
import com.joysuch.wwyt.core.enums.BaseConfigCodes;
import com.joysuch.wwyt.core.security.ShiroUser;
import com.joysuch.wwyt.core.service.AuthorityService;
import com.joysuch.wwyt.core.service.BaseModuleMenuMappingService;
import com.joysuch.wwyt.licence.entity.LicenceModuleAuth;
import com.joysuch.wwyt.licence.service.LicenceModuleAuthService;
import com.joysuch.wwyt.licence.service.LicenceService;
import com.joysuch.wwyt.util.AESUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * licence 过期检测任务
 *
 * @author jialei
 * @date 2022-04-26
 */
@Component
public class LicenceExpiredJob {

    private static final Logger LOGGER = LoggerFactory.getLogger(LicenceExpiredJob.class);

    private final LicenceService licenceService;

    /**
     *
     * @param licenceService
     */
    public LicenceExpiredJob(LicenceService licenceService){
        this.licenceService = licenceService;
    }

    /**
     * 检查licence过期任务
     */
    @Scheduled(cron = "33 33 2 * * ?")
    public void check() {
        DateTime now = DateUtil.date();
        LOGGER.debug("任务开启：{}", now);
        this.licenceService.expired();
        LOGGER.debug("任务结束：{}", DateUtil.date());
    }

}
